package com.foreveross.action;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.foreveross.common.CommonUtil;
import com.foreveross.service.LogService;
import com.foreveross.vo.Log;
import com.foreveross.vo.common.PageVo;
import com.foreveross.vo.common.ResultVo;

@Controller
@RequestMapping(value = "/LogContraller")
public class LogContraller {

	private Logger log = Logger.getLogger(LogContraller.class);

	@Resource
	private LogService logService;
	
	/**
	 * 查看日志列表
	 * @param request
	 * @param response
	 * @param rows
	 * @param page
	 * @param type
	 * @param creater
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/findLogList")
	public void findLogList(HttpServletRequest request,
			HttpServletResponse response, String rows,
			String page,String type,String creater ) {
		ResultVo resultVo = new ResultVo();
		try {
			int countRecord = (int) logService.getLogListCount(type, creater);
			PageVo<Log> pageobj = new PageVo<Log>(page,
					countRecord, rows);
			pageobj.setRows(logService.findLogList(type, creater, pageobj
					.getpageIndex(), pageobj.getpageSize()));
			resultVo.setData(pageobj);
			resultVo.setSuccess(true);
		} catch (Exception e) {
			resultVo.setSuccess(false);
			resultVo.setMessage("系统日志 查看失败");
			log.error("系统日志 查看失败!", e);
		}
		CommonUtil.PrintWriterResultVoWithJSON(response, resultVo);
	}

}
